#!/usr/bin/env python
#-*- coding:utf-8 -*-
# author:Vergil
# datetime:2019/2/25 22:41
# software: PyCharm
from django import forms
from .models import PostList, PostCategory

class PublishForm(forms.ModelForm):
    user = forms.CharField(label='用户', max_length=128, required=False, widget=forms.HiddenInput)
    title = forms.CharField(label='主题名称', max_length=30, widget=forms.TextInput(attrs={'class': 'form-control'}))
    category = forms.ModelChoiceField(label='主题类型', queryset=PostCategory.objects.all()._values('id'),
                                      widget=forms.Select(attrs={'class': 'form-control m-t parsley-validated'}))
    content = forms.CharField(label='主题内容', widget=forms.Textarea(attrs={'class': 'form-control parsley-validated'}))

    class Meta:
        model = PostList
        fields = ('title', 'category', 'content',)